<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.3" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="/favicon.ico?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.3">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.3" color="#222">





  <meta name="keywords" content="css," />





  <link rel="alternate" href="/atom.xml" title="Orton Blog" type="application/atom+xml" />






<meta name="description" content="![环形进度条.gif](https://user-gold-cdn.xitu.io/2018/2/8/1617609ec683e32a?w=315&amp;amp;h=300&amp;amp;f=gif&amp;amp;s=56956) !--(http://upload-images.jianshu.io/upload_images/4060631-d6b24e36947c9cc6.gif?imageMogr2/au">
<meta name="keywords" content="css">
<meta property="og:type" content="article">
<meta property="og:title" content="clip实现圆环进度条">
<meta property="og:url" content="http://ortonzhang.com/2018/02/11/clip-progress-bar/index.html">
<meta property="og:site_name" content="Orton Blog">
<meta property="og:description" content="![环形进度条.gif](https://user-gold-cdn.xitu.io/2018/2/8/1617609ec683e32a?w=315&amp;amp;h=300&amp;amp;f=gif&amp;amp;s=56956) !--(http://upload-images.jianshu.io/upload_images/4060631-d6b24e36947c9cc6.gif?imageMogr2/au">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/4060631-19b6a1622bf7721f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2018-11-27T12:54:03.262Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="clip实现圆环进度条">
<meta name="twitter:description" content="![环形进度条.gif](https://user-gold-cdn.xitu.io/2018/2/8/1617609ec683e32a?w=315&amp;amp;h=300&amp;amp;f=gif&amp;amp;s=56956) !--(http://upload-images.jianshu.io/upload_images/4060631-d6b24e36947c9cc6.gif?imageMogr2/au">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/4060631-19b6a1622bf7721f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://ortonzhang.com/2018/02/11/clip-progress-bar/"/>





  <title>clip实现圆环进度条 | Orton Blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
    <a href="https://github.com/Ortonzhang"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Orton Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Orton Blog</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://ortonzhang.com/2018/02/11/clip-progress-bar/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Orton Zhang">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Orton Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">clip实现圆环进度条</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-02-11T23:12:01+08:00">
                2018-02-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/css/" itemprop="url" rel="index">
                    <span itemprop="name">css</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i> 浏览
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  883
                </span>
              

              

              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>![环形进度条.gif]<br>(<a href="https://user-gold-cdn.xitu.io/2018/2/8/1617609ec683e32a?w=315&amp;h=300&amp;f=gif&amp;s=56956" target="_blank" rel="external">https://user-gold-cdn.xitu.io/2018/2/8/1617609ec683e32a?w=315&amp;h=300&amp;f=gif&amp;s=56956</a>)</p>
<a href="!--(http://upload-images.jianshu.io/upload_images/4060631-d6b24e36947c9cc6.gif?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
--">!--(http://upload-images.jianshu.io/upload_images/4060631-d6b24e36947c9cc6.gif?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
--</a>
<p>怎么实现这样一个圆环进度条的效果呢，可以使用canvas、svg、GIF等等方式，今天我们来说下使用css3怎么来实现。</p>
<a id="more"></a>
<h3 id="实现思路"><a href="#实现思路" class="headerlink" title="实现思路"></a>实现思路</h3><p>圆环很简单，一行css<code>border-radius:50%</code>即可实现，而且没有兼容性问题，什么，你说IE，让它滚…</p>
<p>我们这里需要三个圆环，一个整的，两个半的。大概画了下图 </p>
<p><img src="http://upload-images.jianshu.io/upload_images/4060631-19b6a1622bf7721f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>这里半圆环我使用了<code>clip</code>进行裁剪，主要代码如下,</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.left</span>&#123;</div><div class="line">	<span class="attribute">width</span>: <span class="number">200px</span>;</div><div class="line">	<span class="attribute">height</span>: <span class="number">200px</span>;</div><div class="line">	<span class="attribute">border-radius</span>: <span class="number">50%</span>;</div><div class="line">	<span class="attribute">border</span>: <span class="number">10px</span> solid lightblue;</div><div class="line">	<span class="attribute">position</span>:absolute;</div><div class="line">	<span class="attribute">top</span>: -<span class="number">10px</span>;   <span class="comment">/* 10的原因是因为边框是10个像素 */</span></div><div class="line">	<span class="attribute">right</span>: -<span class="number">10px</span>;</div><div class="line">	<span class="attribute">clip</span>: <span class="built_in">rect</span>(0 100px 200px 0);  <span class="comment">/* 上面为0 右边到100px</span></div><div class="line"><span class="comment">         下面200px 左边到0 这个区域的我们裁剪出来 */</span> </div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>右边类似只是裁剪位置改了</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">.right&#123;</div><div class="line">	width: 200px;</div><div class="line">	height: 200px;</div><div class="line">	border-radius: 50%;</div><div class="line">	border: 10px solid lightblue;</div><div class="line">	position:absolute;</div><div class="line">	top: -10px;  /* 10的原因是因为边框是10个像素 */</div><div class="line">	right: -10px;</div><div class="line">	clip: rect(0 200px 200px 100px);  /* 位置更改，计算可以参考上图 */ </div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="完整代码"><a href="#完整代码" class="headerlink" title="完整代码"></a>完整代码</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div></pre></td><td class="code"><pre><div class="line">&lt;!DOCTYPE html&gt;</div><div class="line">&lt;html lang=&quot;en&quot;&gt;</div><div class="line">&lt;head&gt;</div><div class="line">    &lt;meta charset=&quot;UTF-8&quot;&gt;</div><div class="line">    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;</div><div class="line">    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&gt;</div><div class="line">    &lt;title&gt;Document&lt;/title&gt;</div><div class="line">    &lt;style&gt;</div><div class="line">        div&#123;</div><div class="line">            box-sizing: border-box;</div><div class="line">        &#125;</div><div class="line">        .box&#123;</div><div class="line">            width: 200px;</div><div class="line">            height: 200px;</div><div class="line">            position: relative;</div><div class="line">            background-color: #ccc;</div><div class="line">            border-radius: 50%;</div><div class="line">            left: 40%;</div><div class="line">            top: 200px;</div><div class="line"></div><div class="line">        &#125;</div><div class="line">        .num&#123;</div><div class="line">            position: absolute;</div><div class="line">            top: 50%;</div><div class="line">            left: 50%;</div><div class="line">            background: #fff;</div><div class="line">            border-radius: 50%;</div><div class="line">            width: 180px; </div><div class="line">            height: 180px;</div><div class="line">            transform: translate(-50%, -50%);</div><div class="line">            text-align: center;</div><div class="line">            line-height: 180px;</div><div class="line">            font-size: 32px;</div><div class="line">        &#125;</div><div class="line">        </div><div class="line">        </div><div class="line">        .clip&#123;</div><div class="line">            width: 200px;</div><div class="line">            height: 200px;</div><div class="line">            position: absolute;</div><div class="line">            border: 10px solid #ccc;</div><div class="line">            border-radius: 50%;</div><div class="line">            clip: rect(0, 200px, 200px, 100px);</div><div class="line">        &#125;</div><div class="line">        .left&#123;</div><div class="line">            width: 200px;</div><div class="line">            height: 200px;</div><div class="line">            position: absolute;</div><div class="line">            border: 10px solid lightblue;</div><div class="line">            border-radius: 50%;</div><div class="line">            clip: rect(0 100px 200px 0);</div><div class="line">            top: -10px;</div><div class="line">            left: -10px;</div><div class="line">        &#125;</div><div class="line">        .right&#123;</div><div class="line">            width: 200px;</div><div class="line">            height: 200px;</div><div class="line">            position: absolute;</div><div class="line">            border: 10px solid lightblue;</div><div class="line">            border-radius: 50%;</div><div class="line">            clip: rect(0 200px 200px 100px);</div><div class="line">            top: -10px;</div><div class="line">            left: -10px;</div><div class="line">        &#125;</div><div class="line">        .width-none&#123;</div><div class="line">            width: 0;</div><div class="line">        &#125;</div><div class="line">        .auto&#123;</div><div class="line">            clip: auto;</div><div class="line">        &#125;</div><div class="line">    &lt;/style&gt;</div><div class="line">&lt;/head&gt;</div><div class="line">&lt;body&gt;</div><div class="line">    &lt;div class=&quot;box&quot;&gt;</div><div class="line">        &lt;div class=&quot;clip&quot;&gt;</div><div class="line">            &lt;div class=&quot;left&quot;&gt;&lt;/div&gt;</div><div class="line">            &lt;div class=&quot;right width-none&quot;&gt;&lt;/div&gt;</div><div class="line">        &lt;/div&gt;</div><div class="line">        &lt;div class=&quot;num&quot;&gt;</div><div class="line"></div><div class="line">        &lt;/div&gt;</div><div class="line">    &lt;/div&gt;</div><div class="line">    &lt;script &gt;</div><div class="line">        let clip = document.querySelector(&apos;.clip&apos;),</div><div class="line">        left = document.querySelector(&apos;.left&apos;),</div><div class="line">        right = document.querySelector(&apos;.right&apos;),</div><div class="line">        num = document.querySelector(&apos;.num&apos;),</div><div class="line">        rotate = 0;</div><div class="line">    </div><div class="line">        let loop = setInterval(() =&gt; &#123;</div><div class="line">            if(rotate &gt;= 100)&#123;</div><div class="line">                rotate = 0;</div><div class="line">                right.classList.add(&apos;width-none&apos;);</div><div class="line">                clip.classList.remove(&apos;auto&apos;);</div><div class="line">            &#125; else if(rotate &gt; 50)&#123;</div><div class="line">                right.classList.remove(&apos;width-none&apos;);</div><div class="line">                clip.classList.add(&apos;auto&apos;);</div><div class="line">            &#125;</div><div class="line">            rotate++;</div><div class="line">            left.style.transform = &apos;rotate(&apos;+ 3.6*rotate + &apos;deg)&apos;;</div><div class="line">            num.innerHTML = `$&#123;rotate&#125;%`</div><div class="line">        &#125;,100)</div><div class="line"></div><div class="line">    &lt;/script&gt;</div><div class="line">&lt;/body&gt;</div><div class="line">&lt;/html&gt;</div></pre></td></tr></table></figure>
<p>简单说下上面的代码</p>
<p>1、首先隐藏了右半圆，这是因为我们需要旋转的是左半圆，我们可以等左半圆转到右边圆的位置再显示右    边，就是等到旋转到180度的时候。</p>
<p>2、同时我们看到主圆添加了<code>clip: rect(0, 200px, 200px, 100px);</code>裁剪样式，这是因为默认我们    进度是0%的，我们只显示右边的话才能隐藏左边，但是我们右边不是隐藏的吗？那显示它干嘛呢，因为    旋转左边的时候就看到转到右边的圆了。稍微有点绕，请结合代码，多多理解</p>
<p>3、等到左边旋转了180我们需要将右边显示出来，并且将<code>box</code>元素的裁剪设置为默认值，就是不裁剪，这    这样才能显示完整的左右两个圆。</p>
<p>4、最后我们使用js来控制旋转角度并将百分比显示在页面上</p>
<h3 id="写在最后"><a href="#写在最后" class="headerlink" title="写在最后"></a>写在最后</h3><p>如果上面的解释看不明白，索性就不要看了，把代码放在本地调试下，自己去理解。</p>
<p>别钻牛角尖，代码是最好的语言。</p>
<p>使用clip才实现圆环进度还是很简单的，还不需要考虑兼容性，关于clip可以看<a href="http://www.zhangxinxu.com/wordpress/2011/04/css-clip-rect/" target="_blank" rel="external"><a href="http://www.zhangxinxu.com/wordpress/2011/04/css-clip-rect/" target="_blank" rel="external">张鑫旭大神的日志</a></a></p>

      
    </div>
    
    
    
    
      <div>
        
<div class="my_post_copyright">
  <!-- JS库 sweetalert 可修改路径 -->
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.7.1/jquery.min.js"></script>
  <script src="https://cdn.bootcss.com/sweetalert/1.1.2/sweetalert.min.js"></script>
  <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/sweetalert/1.1.2/sweetalert.min.css">
  <p><span>本文作者:</span><a href="/" title="访问 Orton Zhang 的个人博客">Orton Zhang</a></p>
  <p><span>本文链接:</span><a href="/2018/02/11/clip-progress-bar/" title="clip实现圆环进度条">http://ortonzhang.com/2018/02/11/clip-progress-bar/</a>
  </p>
  <p><span>版权声明:</span>本博客所有文章除特别声明外，均采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank" title="CC BY-NC-SA 3.0 CN">CC BY-NC-SA 3.0 CN</a> 许可协议。转载请注明出处！</p>  
</div>

      </div>
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/css/" rel="tag"><i class="fa fa-tag"></i> css</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/11/25/nginx/" rel="next" title="centos7安装nginx">
                <i class="fa fa-chevron-left"></i> centos7安装nginx
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/02/11/IntersectionObserver/" rel="prev" title="谈谈IntersectionObserver懒加载">
                谈谈IntersectionObserver懒加载 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.gif"
                alt="Orton Zhang" />
            
              <p class="site-author-name" itemprop="name">Orton Zhang</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">5</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          <div class="links-of-author motion-element">
            
              
                <span class="links-of-author-item">
                  <a href="https://github.com/Ortonzhang" target="_blank" title="GitHub">
                    
                      <i class="fa fa-fw fa-globe"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="http://weibo.com/5189572269/profile?rightmod=1&wvr=6&mod=personinfo" target="_blank" title="weibo">
                    
                      <i class="fa fa-fw fa-globe"></i>weibo</a>
                </span>
              
            
          </div>

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#实现思路"><span class="nav-number">1.</span> <span class="nav-text">实现思路</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#完整代码"><span class="nav-number">2.</span> <span class="nav-text">完整代码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#写在最后"><span class="nav-number">3.</span> <span class="nav-text">写在最后</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Orton Zhang</span>

  
</div>



<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共13.0k字</span>
</div>

<span id="busuanzi_container_site_uv">
  访问次数:<span id="busuanzi_value_site_uv"></span>
</span>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  

  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.3"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.3"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.3"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.3"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.3"></script>



  


  




	





  





  












  





  

  

  
  

  

  

  

</body>
</html>
